package com.lz.code.kafka.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: liuzhi
 * @Date: 2022/3/9 22:15
 * @Description:
 */
@RestController
public class KafkaController {

    @Autowired
    private KafkaTemplate<String,String> template;

    @GetMapping("/send")
    public String sendMessage(@RequestParam("msg") String msg) {
        template.send("my-replicated-topic","my-key",msg);
        return "success";
    }

}
